package com.gofaraway.common.enums;

import lombok.Getter;

/**
 * @author ChenPeng
 * @Date 2024/5/15 17:57
 */
@Getter
public enum OssContentTypeEnum {
    /**
     *
     */
    OSS_CONTENT_TYPE_BMP(".bmp", "image/bmp"),
    OSS_CONTENT_TYPE_GIF(".gif", "image/gif"),
    OSS_CONTENT_TYPE_JPE(".jpeg", "image/jpg"),
    OSS_CONTENT_TYPE_JPG(".jpg", "image/jpg"),
    OSS_CONTENT_TYPE_PNG(".png", "image/jpg"),
    OSS_CONTENT_TYPE_HTM(".html", "text/html"),
    OSS_CONTENT_TYPE_DOCX(".docx", "application/msword"),
    OSS_CONTENT_TYPE_DOC(".doc", "application/msword"),
    OSS_CONTENT_TYPE_XML(".xml", "text/xml"),
    OSS_CONTENT_TYPE_XLSX(".xlsx", "application/vnd.ms-excel"),
    OSS_CONTENT_TYPE_XLS(".xls", "application/vnd.ms-excel"),
    OSS_CONTENT_TYPE_XLC(".xlc", "application/vnd.ms-excel"),
    OSS_CONTENT_TYPE_XLM(".xlm", "application/vnd.ms-excel"),
    OSS_CONTENT_TYPE_XLW(".xlw", "application/vnd.ms-excel"),
    ;


    OssContentTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }


    private final String code;

    private final String name;


    public static String getValue(String code) {
        OssContentTypeEnum[] enums = OssContentTypeEnum.values();
        for (OssContentTypeEnum currentEnum : enums) {
            if (currentEnum.getCode().equals(code)) {
                return currentEnum.getName();
            }
        }
        return OSS_CONTENT_TYPE_XLSX.getName();
    }

    public static OssContentTypeEnum getEnum(String code) {
        OssContentTypeEnum[] enums = OssContentTypeEnum.values();
        for (OssContentTypeEnum currentEnum : enums) {
            if (currentEnum.getCode().equals(code)) {
                return currentEnum;
            }
        }
        return null;
    }
}
